﻿<!DOCTYPE html>
<html>
<head>
    <title>JS Operators Exercise 6</title>
    <link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <h1>Checks if given print is within a circle:</h1>
    <div>
        <label for="circle-x">Circle X:</label>
        <input type="number" id="circle-x"/>
        <label for="circle-y">Y:</label>
        <input type="number" id="circle-y"/>
    </div>
    <div>
        <label for="point-x">Point X:</label>
        <input type="number" id="point-x"/>
        <label for="point-y">Y:</label>
        <input type="number" id="point-y"/>
    </div>
    <button onclick="calculate()">Calculate</button>
    <div id="js-console"></div>
    <script src="scripts/js-console.js"></script>
    <script>
        function calculate()
        {
            var circleX;
            var circleY;
            var pointX;
            var pointY;
            var radius = 5;

            circleX = jsConsole.readInteger("#circle-x");
            circleY = jsConsole.readInteger("#circle-y");
            pointX = jsConsole.readInteger("#point-x");
            pointY = jsConsole.readInteger("#point-y");

            if ((((circleX - pointX) * (circleX - pointX)) + ((circleY - pointY) * (circleY - pointY))) < (radius * radius))
            {
                jsConsole.writeLine("Point is inside the circle");
            }
            else
            {
                jsConsole.writeLine("Point is outside the circle");
            }
        }
    </script>
</body>
</html>